﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Forms;

namespace IdragonetEye
{
    public partial class Form_force : Form
    {
        private bool _boolForce;
        private int _haltTime_sec;

        /// <summary>
        /// Initializes a new instance of the <see cref="Form_force"/> class.
        /// </summary>
        /// <param name="boolForce">是否强制休息.</param>
        /// <param name="haltTime">休息时间(秒).</param>
        public Form_force(bool boolForce, int haltTime_sec)
        {
            InitializeComponent();
            _boolForce = boolForce;
            _haltTime_sec = haltTime_sec;
        }

        private void Form_force_Load(object sender, EventArgs e)
        {

            //倒计时窗口屏幕居中
            label_time.Location = new Point((this.Width/2) - (label_time.Width/2), this.Height/2 - label_time.Height/2);

            //强制休息放在右下角
            label_tooltips.Location = new Point((this.Width) - (label_tooltips.Width) - 10,
                this.Height - label_tooltips.Height - 10);

            button_exit.Location = new Point((this.Width) - (button_exit.Width) - 10,
                this.Height - button_exit.Height - 10);

            this.TopMost = true;

           

            RunboolForce(_boolForce);

            timer_xx.Enabled = true;



        }


        /// <summary>
        /// 是否强制休息
        /// </summary>
        /// <param name="_boolForce">if set to <c>true</c> [_bool force].</param>
        private void RunboolForce(bool _boolForce)
        {
            if (_boolForce)
            {
                label_tooltips.Visible = true;
                button_exit.Visible = false;
                //强制隐藏任务栏
                IdragonetEye.Class_force.ShieldTaskBar(0);
                IdragonetEye.Class_force.ShieldMissionTask(1);
            }
            else
            {
                label_tooltips.Visible = false;
                button_exit.Visible = true;
            }
        }

        private void timer_xx_Tick(object sender, EventArgs e)
        {
            label_time.Text = _haltTime_sec.ToString();
            _haltTime_sec = _haltTime_sec - 1;
            if (_haltTime_sec <= -1)
            {
                IdragonetEye.Class_force.ShieldTaskBar(5);
                IdragonetEye.Class_force.ShieldMissionTask(0);
                this.Close();
            }
        }

        private void button_exit_Click(object sender, EventArgs e)
        {
            IdragonetEye.Class_force.ShieldTaskBar(5);
            IdragonetEye.Class_force.ShieldMissionTask(0);
            this.Close();
        }



    }
}